﻿using System.Windows.Input;
using ClientOverflow.DataTransferObjects;
using ClientOverflow.ViewModels.Interfaces;
using ClientOverflow.ViewModels.MainMenus;

namespace ClientOverflow.ViewModels.QuestionsListViewModels
{
    /// <summary>
    /// QuestionViewModel is a view-model that wraps a single question as its model. The view-model is used
    /// in a list context where every question expose its title and a command that allows navigation to the
    /// single question view where the details of the question and its answers are shown.
    /// </summary>
    internal class QuestionViewModel : IQuestionInListViewModel
    {
        public static IQuestionInListViewModel CreateQuestionViewModel(Question question, IMenusViewModel viewModel)
        {
            return new QuestionViewModel(question, viewModel);
        }

        private readonly Question question;

        protected QuestionViewModel(Question question, IMenusViewModel viewModel)
        {
            ShowQuestionCommand = new ShowQuestionCommand(question, viewModel);
            this.question = question;
        }

        public string Title
        {
            get { return question.Title; }
        }

        public ICommand ShowQuestionCommand { get; private set; }
    }
}